<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" href="static/easyui/themes/metro/easyui.css"/>
<link rel="stylesheet" href="static/easyui/themes/icon.css"/>
<title>药房盘点</title>
<body>
<script type="text/javascript">
//门诊
var outpatient_return_amount_box=function(value,row,index){
	var drug_numbesr=row.drug_number;
	var outpatient_pici=row.outpatient_pici;
	var op_returnnumber="";
	$.ajax({
		url:'return_good_amount',
		type:'post',
		async:false,
		dataType:'json',
		data:{
			  drug_number:drug_numbesr,
			  return_details_pici:outpatient_pici,
			  return_goods_type:"门诊药房退药"
		},
		success:function(data){
			//console.log(data+":------------");
			for (var i = 0; i < data.length; i++) {
				op_returnnumber+=data[i].return_goods_allquantity;
			    console.log(data[i].return_goods_allquantity);	
			}
			
		}
	});
	return op_returnnumber;
}
//销毁
var outpatient_destroy_amount_box=function(value,row,index){
	var drug_numbesr=row.drug_number;
	var outpatient_pici=row.outpatient_pici;
	var op_destroynumber="";
	$.ajax({
		url:'destroy_good_amount',
		type:'post',
		async:false,
		dataType:'json',
		data:{
			  drug_number:drug_numbesr,
			  destroy_pici:outpatient_pici,
			  destroy_state:4
		},
		success:function(data){
			//console.log(data+":------------");
			for (var i = 0; i < data.length; i++) {
				op_destroynumber+=data[i].destroy_allquantity;
			}
			
		}
	});
	return op_destroynumber;
}

//住院
var Inhospital_return_amount_box=function(value,row,index){
	var drug_numbesr=row.drug_number;
	var outpatient_pici=row.outpatient_pici;
	var op_returnnumber="";
	$.ajax({
		url:'return_good_amount',
		type:'post',
		async:false,
		dataType:'json',
		data:{
			  drug_number:drug_numbesr,
			  return_details_pici:outpatient_pici,
			  return_goods_type:"住院药房退药"
		},
		success:function(data){
			//console.log(data+":------------");
			for (var i = 0; i < data.length; i++) {
			    op_returnnumber+=data[i].return_goods_allquantity;
			}
			
		}
	});
	return op_returnnumber;
}

//销毁
var Inhospital_destroy_amount_box=function(value,row,index){
	var drug_numbesr=row.drug_number;
	var outpatient_pici=row.outpatient_pici;
	var op_destroynumber="";
	$.ajax({
		url:'destroy_good_amount',
		type:'post',
		async:false,
		dataType:'json',
		data:{
			  drug_number:drug_numbesr,
			  destroy_pici:outpatient_pici,
			  destroy_state:4
		},
		success:function(data){
			//console.log(data+":------------");
			for (var i = 0; i < data.length; i++) {
				op_destroynumber+=data[i].destroy_allquantity;
			}
			
		}
	});
	return op_destroynumber;
}

$(function(){
	var drug_number_arr=[];
	var drug_number_arrs=[];
	//门诊数量差
	var outp_amount_difference_arr=[];
    //原来库存
    var star_oup_storage=[];
	
//开始盘点
$(".add_check").click(function(){
	var rowsdata=$("#drug_room_checkRecord").datagrid("getRows");
	if(rowsdata.length>0){
		var check_time=rowsdata[0].drugchek_time;
		//console.log(check_time);
		var s1 = comFormatDate2(check_time);
		s1 = new Date(s1.replace(/-/g, "/"));
		s2 = new Date();//当前日期
		var days = s2.getTime() - s1.getTime();
		var time = parseInt(days / (1000 * 60 * 60 * 24));
		console.log(time+":-----");
		if(time>=30){
		   $(".add_check_window").window("open");
		}else{
			$.messager.confirm('Confirm', 
					'一个月盘点一次,如需再次盘点请下个月在盘！！', 
					function(r){
			});
		}	
	}else{
		 $(".add_check_window").window("open");
	}
	
	
});

$("#add-check-btn").click(function(){
	 var check_types= $(".check_type").combobox("getValue");
	 if(check_types=="门诊盘点"){
		 $("<form method='post' id='forYesdrug'>").appendTo("body").form({
				url:'insert_checks',
				onSubmit:function(param){
					//盘点类型
					param["drugc.drugchekCategory"] ="门诊盘点";
					
					//门诊还是住院
					param["drugc.drugcheckState"] =4;
					
					//盘点人
					param["drugc.drugchekPeople"] =$("#applypeople").val();
					
					//获取表格中的入库的记录
		            var rows=$("#xinzeng").datagrid("getRows");
				    var total=0;
				    var totalmoney=0;
					for(var  i = 0;i < rows.length; i++){
						//盘点库存总数量
						total +=parseInt(rows[i]["outpatient_storage_amounts"]); 
					    //console.log("盘点库存总数量："+total);
					    
					    //药品编号
					    param["drugcdetail["+i+"].inventory.inventoryNumber"] = rows[i]["drug_number"];
					    //console.log("药品编号："+ param["DrugapplyDetail["+i+"].drug.drugNumber"] );
						
					    //盘点批次
					    param["drugcdetail["+i+"].drugchekdetailsPici"]=rows[i]["outpatient_pici"];
					    
					    //盘点单个药品盘点修改数量
						param["drugcdetail["+i+"].drugchekdetailsShijinumber"]=rows[i]["outpatient_storage_amounts"];
						//console.log("单个药品药量："+param["drugcdetail["+i+"].drugchekdetailsShijinumber"]);
						
						//单个药品原来库存
						param["drugcdetail["+i+"].drugxiaohui"]=star_oup_storage[i];
						
						//盘点单个数量差
						param["drugcdetail["+i+"].drugchekdetailsShuliangcha"]=parseInt(rows[i]["outpatient_storage_amounts"]-outp_amount_difference_arr[i]);
						//console.log("outp_diffrencemoney----------:"+outp_amount_difference_arr[i]);
                         
						//没减的盘点单个数量差
						param["drugcdetail["+i+"].drugtuiyao"]=outp_amount_difference_arr[i];

		                
						//盘点总金额
						totalmoney+=parseInt(rows[i]["outpatient_storage_amounts"]*rows[i]["drug_retail_price"]); 
					
					    //药品价格
					    param["drugcdetail["+i+"].drugchekdetailsSort"]=rows[i]["drug_retail_price"];
					    
					}
					
					//药品盘点总金额
					param["drugc.drugchekAllmoney"]=totalmoney;
					
					//盘点总数量	
					param["drugc.drugchekAllnumber"] =parseInt(total);

				},
				success:function(data){
					if(parseInt(data)==1){
						$(".check-window-apply").text("本次药房盘点成功！！！");
						$("#drug_room_checkRecord").datagrid("reload");
						$("#checksaveclinic-win").window('open');
						$(".add_check_window").window('close');
				    	//三秒之后自动消失
					    setTimeout(function(){
						   $("#checksaveclinic-win").window('close');
						  },3000);
				    	
					    $('#forYesdrug').form("clear");//清空文本
					  
					}
					
					if(parseInt(data)==2){
						$(".check-window-apply").text("盘点失败,请稍后重试....");
						$("#drug_room_checkRecord").datagrid("reload");
						$("#checksaveclinic-win").window('open');
						$(".add_check_window").window('close');
				    	//三秒之后自动消失
					    setTimeout(function(){
						   $("#checksaveclinic-win").window('close');
						  }, 3000);
				    	
					    $('#forYesdrug').form("clear");//清空文本
					}
					
				}
			}).submit();  
	 }
	 
	 if(check_types=="住院盘点"){
		 
	 }
	
});

 //表格双击事件
$('#drug_room_checkRecord').datagrid({
	 onDblClickCell: function(index,field,value){
		    $("#checkRecord-win").window("open");
			var out_patient_rows=$('#drug_room_checkRecord').datagrid("getRows"); 
			var drugchek_id=out_patient_rows[index].drugchek_id;
			//亏损查询
			$('#drug_room_checkRecord_details').datagrid({
				url:'select_checkDetails?drugchek_id='+drugchek_id,
				pagination :true,
				pageNumber : 1,
				pageSize : 10,
				pageList : [10, 5 ],
				columns : [[
					{field : 'outpatient_pici',title : '药品批次',width:80}, 
					{field : 'drug_number',title : '药品编号',width : 120}, 
					{field : 'drug_name',title : '药品名称',width : 123}, 
					{field : 'drug_unit',title : '单位',width:80},
					{field : 'drug_retail_price',title : '售价',width : 120},
					{field : 'drugxiaohui',title : '盘点数量',width:110},
					{field : 'drugchekdetails_shijinumber',title : '盘点后数量',width:120},
					{field : 'drugchekdetails_shuliangcha',title : '数量差',width:130},
					{field : 'drugchekdetails_book',title : '亏损金额',width:120}
				]]	
			});
     }

});



	
//下拉类型
$(".check_type").combobox({
	onSelect:function(record){
		if(record.value=="门诊盘点"){
			//新增界面
			$('#xinzeng').datagrid({
				url:'Check_OutPatientStorage_record',
				onClickCell:onClickCell,
				pagination : true,
				pageNumber : 1,
				pageSize : 7,
				pageList : [ 7, 5 ],
				columns : [[ 
					{field : 'type_name',title : '类型',width : 100},
					{field : 'category_name',title : '类别',width : 100},
					{field : 'outpatient_pici',title : '药品批次',width:76}, 
					{field : 'drug_number',title : '药品编号',width : 100}, 
					{field : 'drug_name',title : '药品名称',width : 110}, 
					{field : 'drug_unit',title : '单位',width:80},
					{field : 'outpatient_storage_amounts',title:'库存数量',width:'100',editor:'numberbox'},
					/* {field : 'outpatient_storage_amounts2',title:'库存数量',width:100,editor:'numberbox',
						 formatter:function(row,value,index){
							 var rows=$("#xinzeng").datagrid("getRows");
							 var ssd=rows[index].outpatient_storage_amounts;
							 return "<a class='Edit_oupt_storage'>"+ssd+"</a>"
						 }
					}, */
					{field : 'outpatient_outamount',title : '出库数量',width : 90}, 
					{field : 'outpatient_inamount',title : '入库数量',width : 90}, 
					{field : 'outpatient_diffrencemoney',title : '数量差',width : 92,
					     formatter:function(row,value,index){
					    	var rows=$("#xinzeng").datagrid("getRows");
					    	var outp_diffrencemoney=0;
					        //出库
							var  outp_outamount=rows[index].outpatient_outamount;
							//入库
							var  outp_inamount=rows[index].outpatient_inamount;
							//数量差
							outp_diffrencemoney=parseInt(outp_inamount)-parseInt(outp_outamount);
							outp_amount_difference_arr.push(outp_diffrencemoney);
						     //存亏损药品id
						     var rowsdatas=$("#xinzeng").datagrid("getRows");
							 if(rows[index].outpatient_outamount!=0 && rows[index].outpatient_inamount!=0  ){
								 if(outp_diffrencemoney!=rows[index].outpatient_storage_amounts){
									 drug_number_arr.push(rows[index].drug_number);
							     } 
							 } 
						     
							return outp_diffrencemoney;
						}
					  }, 
					{field : 'drug_retail_price',title : '售价',width : 80}
				]],
				onLoadSuccess: function(data){
					var rows=$("#xinzeng").datagrid("getRows");
					 //盘点总库存数量
				    var check_agoallamount=0;
				     //盘点数量
				    var check_Presentallamount=0;
				    //亏损数量
				    var check_kuisuAllnamount=0;
				     //亏损金额=库存单个数量差x售价- 数量差x单价
				    var check_kuisun_ALLmoney=0;
				     //总金额
				    var check_Total_Allmoney=0;
				    
				     
				    //数量差数组
				    for (var i = 0; i < outp_amount_difference_arr.length; i++) {
			    		//盘点数量
						check_Presentallamount+=parseInt(outp_amount_difference_arr[i]);
						//console.log("数量差:"+check_Presentallamount);
               		}
					for (var i = 0; i < rows.length; i++) {
						//盘点总库存数量
						check_agoallamount+=parseInt(rows[i].outpatient_storage_amounts);
						
						//亏损金额
						check_kuisun_ALLmoney+=(parseInt(rows[i].outpatient_storage_amounts)*parseInt(rows[i].drug_retail_price))-(parseInt(outp_amount_difference_arr[i])*parseInt(rows[i].drug_retail_price)); 
					   
						//console.log("rows[i].outpatient_storage----:"+(parseInt(outp_amount_difference_arr[i])*parseInt(rows[i].drug_retail_price)));
					 
						//总金额
						check_Total_Allmoney+=parseInt(rows[i].outpatient_storage_amounts)*parseInt(rows[i].drug_retail_price)
					    
						//将开始库存用数组存着
	                    star_oup_storage.push(rows[i].outpatient_storage_amounts);
						//console.log("原来库存---："+star_oup_storage);
					}
					
					//亏损数计算
				    check_kuisuAllnamount=parseInt(check_agoallamount)-parseInt(check_Presentallamount);
					
					 //盘点总库存数量
					$("#check_agoamount").textbox("setValue",check_agoallamount);
					//盘点数量
					$("#check_Presentamount").textbox("setValue",check_Presentallamount);
                    //亏损数量
                    $("#check_kuisunamount").textbox("setValue",check_kuisuAllnamount);
					//亏损金额
                    $("#check_kuisun_money").textbox("setValue",check_kuisun_ALLmoney);
                   	//总金额
                    $("#check_Total_money").textbox("setValue",check_Total_Allmoney);
                    
                   
                   	if(check_agoallamount!=check_Presentallamount){
                 		$("#outpatient_kuisunrecord").show();
                    }
				}
			});
		}
		if(record.value=="住院盘点"){
			var hos_amount_difference_arr=[];
			//新增界面
			$('#xinzeng').datagrid({
				url:'check_InhospitalStorage_record',
				pagination : true,
				pageNumber : 1,
				pageSize : 7,
				pageList : [ 7, 5],
				columns : [[ 
					{field : 'type_name',title : '类型',width : 100},
					{field : 'category_name',title : '类别',width : 80}, 
					{field : 'inhospital__pici',title : '批次',width : 76},
					{field : 'drug_number',title : '药品编号',width : 120}, 
					{field : 'drug_name',title : '药品名称',width : 110}, 
					{field : 'drug_unit',title : '单位',width : 80}, 
					{field : 'inhospital_storage_amounts',title : '库存',width : 90}, 
					{field : 'Inhospital_outAmount',title : '出库数量',width : 90}, 
					{field : 'Inhospital_inAmount',title : '入库数量',width : 100}, 
					{field : 'Inhospital_diffrencemoney',title : '数量差',width : 92,
						 formatter:function(row,value,index){
					    	 var rows=$("#xinzeng").datagrid("getRows");
					    	 var Inhos_diffrencemoney=0;
					    	 //出库
							var  Inhos_outAmount=rows[index].Inhospital_outAmount;
							//入库
							var  Inhos_inAmount=rows[index].Inhospital_inAmount;
							//数量差
							Inhos_diffrencemoney=parseInt(Inhos_inAmount)-parseInt(Inhos_outAmount);
							hos_amount_difference_arr.push(Inhos_diffrencemoney);
							if(rows[index].Inhospital_outAmount!=0 && rows[index].Inhospital_inAmount!=0  ){
							 if(Inhos_diffrencemoney!=rows[index].inhospital_storage_amounts){
								 if(drug_number_arrs[index]!=rows[index].drug_number){
									 drug_number_arrs.push(rows[index].drug_number);
								 }
							 }
							} 
							return Inhos_diffrencemoney;
						}	
				   }, 
					{field : 'drug_retail_price',title : '售价',width : 80}
				] ],
				onLoadSuccess:function(data){
				 var rows=$("#xinzeng").datagrid("getRows");
				 //盘点总库存数量
			     var check_agoallamount=0;
			     //盘点数量
			     var check_Presentallamount=0;
			    //亏损数量
			     var check_kuisuAllnamount=0;
			     //亏损金额=库存单个数量差x售价- 数量差x单价
			     var check_kuisun_ALLmoney=0;
			     //总金额
			     var check_Total_Allmoney=0;
			     
			     //数量差数组
			    for (var i = 0; i <hos_amount_difference_arr.length; i++) {
			    	//盘点数量
					check_Presentallamount+=parseInt(hos_amount_difference_arr[i]);
					//console.log("check_Presentallamount--盘点数量--:"+rows[i].outpatient_diffrencemoney);
				}
			     
				for (var i = 0; i < rows.length; i++) {
				      //盘点总库存数量
				      check_agoallamount+=parseInt(rows[i].inhospital_storage_amounts);
					  //console.log(check_agoallamount+":库存总数量---------："+rows[i].Inhospital_outAmount);
				      
					  //亏损金额
					  check_kuisun_ALLmoney+=(parseInt(rows[i].inhospital_storage_amounts)*parseInt(rows[i].drug_retail_price))-(parseInt(hos_amount_difference_arr[i])*parseInt(rows[i].drug_retail_price)); 
				   
					  //总金额
					  check_Total_Allmoney+=parseInt(rows[i].inhospital_storage_amounts)*parseInt(rows[i].drug_retail_price)
				 }
				 //亏损数计算
			    check_kuisuAllnamount=parseInt(check_agoallamount)-parseInt(check_Presentallamount);
				
				 //盘点总库存数量
				$("#check_agoamount").textbox("setValue",check_agoallamount);
				//盘点数量
				$("#check_Presentamount").textbox("setValue",check_Presentallamount);
                //亏损数量
                $("#check_kuisunamount").textbox("setValue",check_kuisuAllnamount);
	       		//亏损金额
                $("#check_kuisun_money").textbox("setValue",check_kuisun_ALLmoney);
                //总金额
                $("#check_Total_money").textbox("setValue",check_Total_Allmoney);
                // console.log("盘点前数量："+check_agoallamount+"盘点后数量----------"+check_Presentallamount);  	
                   	 if(check_agoallamount!=check_Presentallamount){
                   		$("#outpatient_kuisunrecord").show();
                   	 }
			    }
			});
		}
	}
});

//门诊退药数量编辑
$.extend($.fn.datagrid.methods,{
		editCell: function(jq,param){
			return jq.each(function(){
				var opts = $(this).datagrid('options');
				var fields = $(this).datagrid('getColumnFields',true).concat($(this).datagrid('getColumnFields'));
				for(var i=0; i<fields.length; i++){
					var col = $(this).datagrid('getColumnOption', fields[i]);
					col.editor1 = col.editor;
					if (fields[i] != param.field){
						col.editor = null;
						
					}
				}
				$(this).datagrid('beginEdit', param.index);
				
				for(var i=0; i<fields.length; i++){
					var col = $(this).datagrid('getColumnOption', fields[i]);
					col.editor = col.editor1;
				}
			});
		}
	});
	
	var editIndex = undefined;
	function endEditing(){
		if (editIndex == undefined){return true}
		if ($("#xinzeng").datagrid('validateRow', editIndex)){
			$("#xinzeng").datagrid('endEdit', editIndex);
			editIndex = undefined;
			return true;
		} else {
			return false;
		}
	}
	function onClickCell(index, field){
		if (endEditing()){
			$("#xinzeng")
			.datagrid('selectRow', index)
					.datagrid('editCell', {index:index,field:field});
			editIndex = index;
		}
	}

  //门诊亏损
  $("#outpatient_kuisunrecord").click(function(){
	 var check_types= $(".check_type").combobox("getValue");
	 if(check_types=="门诊盘点"){
		$(".bad_title").text("门诊出入库记录");
		   $("#kuisun-win").window("open");
		   //门诊所有出入库记录
			$("#outpatient_kuisun_tab").datagrid({
				url:'select_oupatient_badamount?drug_number_arr='+drug_number_arr,
				pagination : true,
				pageNumber : 1,
				pageSize : 15,
				pageList : [ 15, 14,13],
				columns : [[ 
					{field : 'type_name',title : '类型',width : 100},
					{field : 'category_name',title : '类别',width : 100},
					{field : 'outpatient_pici',title : '药品批次',width:96}, 
					{field : 'drug_number',title : '药品编号',width : 100}, 
					{field : 'drug_name',title : '药品名称',width : 110}, 
					{field : 'drug_unit',title : '单位',width:110},
					{field : 'drug_retail_price',title : '售价',width : 100},
					{field : 'outpatient_return_amount',title : '退药数量',width:85,
					       	formatter:outpatient_return_amount_box	
					}, 
					{field : 'outpatient_destroy_amount',title : '销毁数量',width:85,
							formatter:outpatient_destroy_amount_box	
					},
					{field : 'outpatient_inamount',title : '入库数量',width:86},
					{field : 'outpatient_outamount',title : '发药数量',width:60}

				]]
    		})
         }
	 
	   if(check_types=="住院盘点"){
	   $("#kuisun-win").window("open");
		$("#outpatient_kuisun_tab").datagrid({
			url:'select_Inhospital_badamount?drug_number_arrs='+drug_number_arrs,
			pagination : true,
			pageNumber : 1,
			pageSize : 15,
			pageList : [ 15, 14,13],
			columns : [[
					{field : 'type_name',title : '类型',width : 100},
					{field : 'category_name',title : '类别',width : 100},
					{field : 'inhospital__pici',title : '药品批次',width:96}, 
					{field : 'drug_number',title : '药品编号',width : 100}, 
					{field : 'drug_name',title : '药品名称',width : 110}, 
					{field : 'drug_unit',title : '单位',width:110},
					{field : 'drug_retail_price',title : '售价',width : 100},
					{field : 'outpatient_return_amount',title : '退药数量',width:105,
					       	formatter:Inhospital_return_amount_box	
					}, 
					{field : 'outpatient_destroy_amount',title : '销毁数量',width:105,
							formatter:Inhospital_destroy_amount_box	
					},
					{field : 'hospital_inamount',title : '入库数量',width:106}
			]]
   		})
        }
	});
  
  $("#drug_room_checkRecord").datagrid({
	  url:'select_check',
	  pagination : true,
	  pageNumber : 1,
	  pageSize : 15,
	  pageList : [ 15, 14,13],
	  columns : [[
		    {field : 'drugchek_id',title : '盘点单号',width :145},
		    {field : 'drugcheck_state',title : '部门库存',width : 132,
		          formatter:function(value,row,index){
		        	  if(parseInt(value)==4){
		        		 return "门诊药房盘点";  
		        	  }
		          }
		    },
			{field : 'drugchek_allnumber',title : '盘点前总数量',width : 100},
			{field : 'drugchek_allmoney',title : '盘点总金额',width:120}, 
			{field : 'drugcheck_twopeople',title : '盘点数量差',width : 140}, 
			{field : 'drugcheck_differencemoney',title : '亏损金额',width :120},
			{field : 'drugchek_time',title : '盘点时间',width : 140,formatter:comFormatDate},
			{field : 'drugchek_people',title : '盘点的人',width :120}
	  ]]
  });
 		
 });
 
//格式化时间
function comFormatDate2(date) {
	var day = new Date(date); 
	var Year = 0; 
	var Month = 0; 
	var Day = 0; 
	var CurrentDate = ""; 
	//初始化时间 
	Year= day.getFullYear();//ie火狐下都可以 
	Month= day.getMonth()+1; 
	Day = day.getDate(); 
	CurrentDate += Year + "-"; 
	if (Month >= 10 ) { 
		CurrentDate += Month + "-"; 
	}else { 
		CurrentDate += "0" + Month + "-"; 
	} 
	if (Day >= 10 ) { 
		CurrentDate += Day ; 
	}else { 
		CurrentDate += "0" + Day ; 
	} 
	
	return CurrentDate; 
}

function comFormatDate(date) {
	var day = new Date(date); 
	var Year = 0; 
	var Month = 0; 
	var Day = 0; 
	var CurrentDate = ""; 
	//初始化时间 
	Year= day.getFullYear();//ie火狐下都可以 
	Month= day.getMonth()+1; 
	Day = day.getDate(); 
	Hour = day.getHours(); 
	 Minute = day.getMinutes(); 
	 Second = day.getSeconds(); 
	CurrentDate += Year + "-"; 
	if (Month >= 10 ) { 
		CurrentDate += Month + "-"; 
	}else { 
		CurrentDate += "0" + Month + "-"; 
	} 
	if (Day >= 10 ) { 
		CurrentDate += Day ; 
	}else { 
		CurrentDate += "0" + Day ; 
	} 
	if(Hour>=10){
		CurrentDate +=" "+Hour;
	}else{
		CurrentDate +=" "+"0"+Hour;
	}
	if(Minute>=10){
		CurrentDate +=":"+Minute;
	}else{
		CurrentDate +=":"+"0"+Minute;
	}
	if(Second>=10){
		CurrentDate +=":"+Second;
	}else{
		CurrentDate +=":"+"0"+Second;
	}
	return CurrentDate; 
}
</script>

 <fieldset style="border:1px solid #A6A6A6;border-radius:6px;width:1056px;margin:0 auto;margin-top:10px;height:450px;">
	  <legend style="font-size:17px">盘点记录</legend>
	  <div style="margin-left: 15px;margin-top:8px;">
	      <a class="add_check easyui-linkbutton" iconCls="icon-add">开始盘点</a>
	  </div> 
	  <div style="margin-top:8px;margin-left: 15px;">
	    <table id="drug_room_checkRecord" class="easyui-datagrid"style="width:1020px; height:350px"data-options="fitColumns:false,singleSelect:false">
				
		</table>
	  </div>
</fieldset>

<!-- 药品详情界面 -->
<div id="kuisun-win" class="easyui-window" title="药房药品亏损详情记录"
	style="width: 1080px; height: 530px"
	data-options="iconCls:'icon-save',modal:true,closed:true,shadow:true,resizable:false,collapsible:false,minimizable:false,maximizable:false">
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'center'">
			<div style="width: 1040px; height: 58px;">
				<h1 class="bad_title" style="text-align:center;font-family:华文楷体;font-size : 30px;">住院出入库记录</h1>
			</div>
			<div style="margin-left: 20px;">
				<table id="outpatient_kuisun_tab" class=" easyui-datagrid"style="width: 1034px; height: 408px"data-options="fitColumns:false,singleSelect:false">
					
				</table>
			</div>
		</div>
	</div>
</div>

<!-- 新增盘点 -->
<div class="add_check_window easyui-window" title="药房药品盘点" style="width:1080px;height:560px" data-options="iconCls:'icon-save',modal:true,closed:true,shadow:true,resizable:false,collapsible:false,minimizable:false,maximizable:false" >
	    <div style="width: 1040px; height: 58px;">
			<h1 class="chekc_title" style="text-align:center;font-family:华文楷体;font-size : 30px;">药房药品盘点</h1>
		</div>
	    <div style="margin-left:20px;margin-bottom:10px;">
	        <select class="check_type easyui-combobox"  data-options="panelHeight:'auto' " style="margin-top: 6px;width:100px;height:28px;">
					   <option value="住院盘点">住院盘点</option>
					   <option value="门诊盘点">门诊盘点</option>
		    </select>
		    <span style="margin-left:82%;">
		       <a class="easyui-linkbutton"  id="outpatient_kuisunrecord"  style="display:none;">查看亏损</a>
		    </span>
	    </div>
		<div style="margin-left: 20px;">
				<table id="xinzeng" class="logininform-table easyui-datagrid"style="width: 1020px; height: 250px"data-options="fitColumns:false,singleSelect:false">
				
				</table>
		 </div>
		 <div style="margin-left: 20px;height:30px;margin-right: 20px;margin-top:25px;">
				<span style="margin-right:7px;margin-left:13px;">总库存数量</span>
				 <a class="easyui-textbox" id="check_agoamount" style="width: 120px" data-options="readonly:true"></a>
				<span style="margin-left: 200px;margin-right:7px;">盘点数量</span>
				 <a class="easyui-textbox"  id="check_Presentamount" style="width: 120px" data-options="readonly:true"></a>
				<span style="margin-left: 234px">亏损数量</span>
			     <a class="easyui-textbox" id="check_kuisunamount" style="width: 120px" data-options="readonly:true"></a>
		   </div>
		   <div style="margin-left:33px;height:30px;margin-right: 20px;margin-top:20px;">
				<span style="margin-right:18px;">亏损金额</span>
				<a class="easyui-textbox" id="check_kuisun_money" style="width: 120px" data-options="readonly:true"></a>
				<span style="margin-left: 200px;margin-right: 20px;">总金额</span>
		     	<a class="easyui-textbox" id="check_Total_money" style="width: 120px" data-options="readonly:true"></a>
		  </div>
		  <p style="margin-left:44%;">
		    <a class="easyui-linkbutton" id="add-check-btn" iconCls="icon-ok">确定</a>
		  </p>
</div>

<div id="checkRecord-win" class="easyui-window" title="盘点详情"style="width: 1020px; height: 500px"
data-options="iconCls:'icon-save',modal:true,closed:true,shadow:true,resizable:false,collapsible:false,minimizable:false,maximizable:false">
	<table id="drug_room_checkRecord_details" class=" easyui-datagrid" style="width:100%; height:450px"data-options="fitColumns:false,singleSelect:false">
					
	</table>
</div>

<input type="hidden" value="${user.userName}" id="applypeople">
<!-- 弹框提示 -->
<div id="checksaveclinic-win" class="easyui-window" title="提示框"
	style="width: 300px; height: 156px"
	data-options="iconCls:'icon-save',modal:true,resizable:false,collapsible:false,maximizable:false,minimizable:false,closed:true">
	<p class="check-window-apply"
		style="margin-left:67px; font-size: 16px; margin-top: 47px;"></p>
</div>
</body>
</html>